# Maintainer: Bruno Pagani <archange@archlinux.org>

_pkg=pyscreenshot
pkgname=python-${_pkg}
pkgver=3.1
pkgrel=2
pkgdesc="Copy the contents of the screen to a PIL or Pillow image memory"
arch=(any)
url="https://github.com/ponty/pyscreenshot"
license=(BSD)
depends=(python-easyprocess python-entrypoint2 python-mss python-jeepney)
makedepends=(python-setuptools)
checkdepends=(
    python-pytest python-pyvirtualdisplay python-pillow python-path.py python-pygame
    python-xlib python-gobject python-pyqt5 python-wxpython pyside2
    xorg-server-xvfb xorg-xdpyinfo gnome-screenshot scrot imagemagick
    maim pqiv
)
source=(https://files.pythonhosted.org/packages/source/${_pkg::1}/${_pkg}/${_pkg}-${pkgver}.tar.gz)
#source=(${url}/archive/${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('8c0e93f0aef66a6bfe55a86abfced6bd396ae4b4f6cc1e36f04a28ad2625594d')

build() {
  cd ${_pkg}-${pkgver}
  python setup.py build
}

check() {
  cd ${_pkg}-${pkgver}
  export PYTHONPATH="${PWD}/build/lib/" 
  python -m pyscreenshot.check.versions
#  python -m pyscreenshot.check.speedtest --virtual-display
  xvfb-run -n 101 -s "+extension RANDR -br -screen 0 900x800x24" python -m pytest -v
  xvfb-run -n 102 -s "-extension RANDR -br -screen 0 900x800x24" python -m pytest -v
}

package() {
  cd ${_pkg}-${pkgver}
  python setup.py install --prefix=/usr --root="${pkgdir}" --skip-build --optimize=1
  install -Dm644 LICENSE.txt -t "${pkgdir}"/usr/share/licenses/${pkgname}
}
